home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / src / WBBump_src.lha / WBBump_src / brighttable.e < prev    next >
Encoding:
Text File  |  1999-06-30  |  1.4 KB  |  65 lines

  1. /* ************* */
  2. /* brigthtable.e */
  3. /* ************* */
  4.  
  5.  
  6.  
  7. /*
  8.     WBBump - Bumpmapping on the Workbench!
  9.  
  10.     Copyright (C) 1999  Thomas Jensen - dm98411@edb.tietgen.dk
  11.  
  12.     This program is free software; you can redistribute it and/or modify
  13.     it under the terms of the GNU General Public License as published by
  14.     the Free Software Foundation; either version 2 of the License, or
  15.     (at your option) any later version.
  16.  
  17.     This program is distributed in the hope that it will be useful,
  18.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20.     GNU General Public License for more details.
  21.  
  22.     You should have received a copy of the GNU General Public License
  23.     along with this program; if not, write to the Free Software Foundation,
  24.     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  25. */
  26.  
  27.  
  28.  
  29.  
  30. OPT MODULE
  31.  
  32.  
  33.  
  34. EXPORT PROC get_brighttable()
  35.     DEF    i,
  36.         ix, iy, temp,
  37.         scale,
  38.         btab=NIL
  39.  
  40.     scale := 2.5
  41.  
  42.     btab := NewR(256*256)
  43.  
  44.     i := 0
  45.     FOR iy := 0 TO 255
  46.         FOR ix := 0 TO 255
  47.             temp := dist_fp(0, 0, ix, iy, scale)
  48.             btab[i] := (IF temp<256 THEN temp ELSE 255)
  49.             i++
  50.         ENDFOR
  51.     ENDFOR
  52. ENDPROC btab
  53.  
  54.  
  55. PROC dist_fp(x1, y1, x2, y2, scale /* float */)
  56.     DEF    dx, dy, d
  57.  
  58.     dx := x1 - x2
  59.     dy := y1 - y2
  60.  
  61.     d := !Fsqrt((dx*dx!*scale!) + (dy*dy!*scale!)!)!
  62.  
  63. ENDPROC IF (d>255) THEN 255 ELSE d
  64.  
  65.